<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .box{
            border: 1px solid red;
            border-radius: 10px;
            width: 240px;
            height: 200px;
            position: relative;
            text-align: center;
            margin: 200px auto;
        }
        .box input{
            line-height: 30px;
            margin: 10px 20px;
            border-radius: 15px;
            outline: none;
        }
        .box input[type="submit"]{
            width: 60px;
        }
        .box div{
            position: absolute;
            right: 10px;
            bottom: 10px;
        }
        .box div a{
           color: red;
            text-decoration: none;
            font-size: 12px;
        }
    </style>
    <script src="https://cdn.staticfile.net/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
    <div class="box">
        <form>
            <input id="username" type="text" name="username" placeholder="请输入用户名" autocomplete="off"><br/>
            <input id="password" type="password" name="password" placeholder="请输入密码"><br/>
            <input type="button" value="登&nbsp;&nbsp;录" id="submit">
        </form>
    </div>
</body>
<script>
    $("#submit").click(function (){
        $.ajax({
            type:"post",
            url:"/user/login",
            contentType: "application/json", // 设置内容类型为 JSON
            data: JSON.stringify({
                username: $("#username").val(),
                password: $("#password").val()
            }),
            success: function (res){
                if (res=="true"){
                    location.href="admin/infor.html"
                } else {
                    alert("登陆失败")
                }
            }
        })
    })
</script>
</html>
